//
//  PlayViewController.m
//  音悦咖
//
//  Created by dllo on 15/7/13.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "PlayViewController.h"
#import "AFNetworkHandler.h"
#import "STKAudioPlayer.h"
#import "L_Singleton.h"
#import "UIImageView+WebCache.h"
#import "UIImageView+WebCache.h"
#import "L_footPlaytabBar.h"
#import "L_PlayListView.h"
#import <AVFoundation/AVFoundation.h>

@interface PlayViewController () <UITableViewDataSource, UITableViewDelegate>{
    NSInteger modelNum;
    BOOL lrcTableViewHidden;
    NSInteger lrcLineNumber;
    
}

@property (nonatomic, retain)NSString *lrcId;
@property (nonatomic, retain) NSString *playUrl;
@property (nonatomic, retain) L_Singleton *single;
@property (nonatomic, retain) NSTimer *time;
@property (nonatomic, retain) CABasicAnimation *rotationAnimation;
@property (nonatomic, retain) NSDictionary *dic;
@property (nonatomic, retain) UITableView *PlayListView;
@property (nonatomic, assign) BOOL isCircle;  // 播放模式
@property (nonatomic, retain) NSMutableArray *firstLrcArr;
@property (nonatomic, retain) NSMutableDictionary *LRCDictionary;
@property (nonatomic, retain) NSMutableArray *timeArray;
@property (nonatomic, retain) NSMutableArray *LRCArray;
@property (nonatomic, retain) UITableView *lrcTableView;
@property (nonatomic, retain) L_PlayListView *playlist;


@end

@implementation PlayViewController

- (void)dealloc
{
    [_lrcId release];
    [_PlayArr release];
    [_array release];
    [_song_id release];
    [_playUrl release];
    [_playView release];
    [_time release];
    [_rotationAnimation release];
    [_dic release];
    [_PlayListView release];
    [_firstLrcArr release];
    [_LRCDictionary release];
    [_timeArray release];
    [_LRCArray release];
    [_lrcTableView release];
    [super dealloc];
}


- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.single = [L_Singleton shareManager];
    }
    return self;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   // [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
   
   
        
    //
    self.view.backgroundColor = [UIColor whiteColor];
    [self getData];
    // 创建歌词tableView
    [self createLRCTableView];
    // 创建播放列表视图
    [self createPlayListViews];
    
    // 判断是否播放
    if ([self.single.state isEqualToString:@"playing"]) {
        // 设置定时器
        self.time = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(progressAction) userInfo:nil repeats:YES];
    } else {
        // 设置定时器
        self.time = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(progressAction) userInfo:nil repeats:YES];
        // 定时器暂停
        [self.time setFireDate:[NSDate distantFuture]];
    }
    
//    self.time = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(progressAction) userInfo:nil repeats:YES];

    
//    AVAudioSession *session = [AVAudioSession sharedInstance];
//    [session setActive:YES error:nil];
//    [session setCategory:AVAudioSessionCategoryPlayback error:nil];
}



#pragma mark - 网络请求,对视图进行赋值
- (void)getData
{
    // 创建页面
    self.playView = [[L_PlayView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:self.playView];
    [_playView release];
//    self.playView.backImage.image = [UIImage imageNamed:@"playBackImage1.jpg"];
    
    [self.playView.backButton addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
    
    _isCircle = YES;
    // 获取数据
    self.song_id = self.single.song_id;
    NSString *str = [NSString stringWithFormat:@"http://ting.hotchanson.com/songs/downwhite?song_id=%@", self.song_id];
    
    // 网络请求
    [AFNetworkHandler GETWithAFNByURL:str completion:^(id result) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        dic = [[result objectForKey:@"data"] lastObject];
        
        PlayerModel *playModel = [[PlayerModel alloc] initWithDic:dic];
        
        // 如果不添加会Crash
        if ([self.single.array containsObject:playModel]) {
            
        } else {
            [self.single.array addObject:playModel];
        }
//        // 获取index位置
//        for (NSInteger i = 0; i < self.single.array.count; i++) {
//            if ([[self.single.array[i] song_name] isEqualToString:playModel.song_name]) {
//                self.single.index = i;
//                break;
//            }
//            
//        }
        
        // 旋转动画初始化
        self.rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
        _rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0];
        _rotationAnimation.duration = 10;
        _rotationAnimation.repeatCount = NSIntegerMax;
        
        [self transform];
        
        
        
        // 本界面的播放路径
        self.playUrl = [[[self.single.array[self.single.index] url_list] firstObject] objectForKey:@"url"];
        self.single.playUrl = self.playUrl;
        
        
        self.playView.playTime.text = @"00:00";
        self.playView.surplusTime.text = @"00:00";
        self.playView.title.text = [self.single.array[self.single.index] song_name];
        self.playView.songerName.text = [self.single.array[self.single.index] singer_name];
        [self.playView.showImage setImageWithURL:[NSURL URLWithString:[[[self.single.array[self.single.index] mv_list] firstObject] objectForKey:@"pic_url"]] placeholderImage:[UIImage imageNamed:@"playCard.jpg"]];
        [self.playView.playList setImage:[UIImage imageNamed:@"playList1.png"] forState:UIControlStateNormal];
        
        // 获取歌词
        [self getLRC];
        
    }];
    
    
    
    // 播放按钮
    if ([self.single.state isEqualToString:@"playing"]) {
        [self.playView.play setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
    } else {
        [self.playView.play setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
    }
    [self.playView.play addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
    
    // 上一首
    [self.playView.upSong setImage:[UIImage imageNamed:@"upSong.png"] forState:UIControlStateNormal];
    [self.playView.upSong addTarget:self action:@selector(upSongAction:) forControlEvents:UIControlEventTouchUpInside];
    
    // 下一首
    [self.playView.nextSong setImage:[UIImage imageNamed:@"nextSong.png"] forState:UIControlStateNormal];
    [self.playView.nextSong addTarget:self action:@selector(nextSongAction:) forControlEvents:UIControlEventTouchUpInside];
    
    // 播放模式
    [self.playView.playPattern setImage:[UIImage imageNamed:@"xunhuanplay.png"] forState:UIControlStateNormal];
    [self.playView.playPattern addTarget:self action:@selector(playPatternAction) forControlEvents:UIControlEventTouchUpInside];
    
    // 播放列表
    [self.playView.playList addTarget:self action:@selector(playListAction:) forControlEvents:UIControlEventTouchUpInside];
    
}


#pragma mark - 获取歌词
- (void)getLRC
{

        
        NSString *URLStr = [NSString stringWithFormat:@"http://api.raventech.cn/api/music/search?album_name=&appkey=54679361&appversion=ios1.3.0&cate_type=0&client_time=2015-05-21%2015%3A28%%3A39&content=--%@--&deviceid=86D47CC5-7337-4186-98C3-6EB77C5C8CD3&deviceusername=%%25E5%%25A4%%25AA%%25E9%2598%25B3&key=--%@--&network_type=1&page=1&searchtype=0&singer_name=&song_name=&type=0&zone=Asia%%252FShanghai%2520%2528GMT%%252B8%%2529", [self.single.array[_single.index] song_name], [self.single.array[_single.index] song_name]];
        
        [AFNetworkHandler GETWithAFNByURL:URLStr completion:^(id result) {
            NSArray *dataArr = [[result objectForKey:@"info"] objectForKey:@"data"];
            
            self.lrcId = @"0";
            for (NSDictionary *dic  in dataArr) {
                if ([[dic objectForKey:@"singer_name"] isEqualToString:[self.single.array[_single.index] singer_name]]) {
                    self.lrcId = [dic objectForKey:@"id"];
                    break;
                }
            }
            
            NSLog(@"~~~~~~~~~id = %@", self.lrcId);
            
            
            if (![self.lrcId isEqualToString:@"0"]) {
                

                self.LRCDictionary = [NSMutableDictionary dictionary];
                self.timeArray = [NSMutableArray array];
                
                NSString *str = [NSString stringWithFormat:@"http://api.raventech.cn/api/music/lyric?id=%@", self.lrcId];
                
                [AFNetworkHandler GETWithAFNByURL:str completion:^(id result) {
                    NSString *lrc = [[result objectForKey:@"info"] objectForKey:@"lyric"];
                    
                    NSArray *tempArray = [lrc componentsSeparatedByString:@"\n"];
                    
                    for (int i = 0; i < tempArray.count; i++) {
                        NSString *linStr = [tempArray objectAtIndex:i];
                        NSArray *lineArray = [linStr componentsSeparatedByString:@"]"];
                        if ([lineArray[0] length] > 7) {
                            NSString *str1 = [linStr substringWithRange:NSMakeRange(3, 1)];
                            NSString *str2 = [linStr substringWithRange:NSMakeRange(6, 1)];
                            if ([str1 isEqualToString:@":"] && [str2 isEqualToString:@"."]) {
                                NSString *lrcStr = [lineArray objectAtIndex:1];
                                NSString *timeStr = [[lineArray objectAtIndex:0] substringWithRange:NSMakeRange(1, 5)]; //分割区间求歌词时
                                
                                //把时间 和 歌词 加入词典
                                [self.LRCDictionary setObject:lrcStr forKey:timeStr];
                                [self.timeArray addObject:timeStr]; //timeArray的count就是行数
                                
                            }
                            
                        }
                        
                    }
                   
                    [self.lrcTableView reloadData];
                    //[self createLRCTableView];
                    
                }];
                
                
            }
            
            
        }];
    

}

#pragma mark - 创建歌词的tableView
- (void)createLRCTableView
{
    self.lrcTableView = [[UITableView alloc] initWithFrame:self.playView.backImage.bounds style:UITableViewStylePlain];
    self.lrcTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.lrcTableView.backgroundColor = [UIColor clearColor];
    self.lrcTableView.tag = 20100;
    self.lrcTableView.delegate = self;
    self.lrcTableView.dataSource = self;
    [self.playView.backImage addSubview:self.lrcTableView];
    [_lrcTableView release];
    
}

#pragma mark - 动态显示歌词
- (void)displaySongWord:(NSInteger)time
{
    for (int i = 0; i < self.timeArray.count; i++) {
        
        NSArray *tempArr = [self.timeArray[i] componentsSeparatedByString:@":"];//把时间转换成秒
        NSInteger currentTime =[tempArr[0] intValue] * 60 + [tempArr[1] intValue];
        if (i == [self.timeArray count] - 1) {
            //求最后一句歌词的时间点
            NSArray *tempArr1 = [self.timeArray[self.timeArray.count - 1] componentsSeparatedByString:@":"];
            NSInteger currenttime1 = [tempArr1[0] intValue] * 60 + [tempArr1[1] intValue];
            if (time > currenttime1) {
                [self updateLrcTableView:i];
                break;
            }
            
        } else {
            //求出第一句的时间点，在第一句显示前的时间内一直加载第一句
            NSArray *tempArr2 = [self.timeArray[0] componentsSeparatedByString:@":"];
            NSUInteger currentTime2 = [tempArr2[0] intValue] * 60 + [tempArr2[1] intValue];
            if (time < currentTime2) {
                [self updateLrcTableView:0];
                break;
            }
            //求出下一步的歌词时间点，然后计算区间
            NSArray *tempArr3 = [self.timeArray[i + 1] componentsSeparatedByString:@":"];
            NSInteger currentTime3 = [tempArr3[0] intValue] * 60 + [tempArr3[1] intValue];
            if (time >= currentTime && time < currentTime3) {
                [self updateLrcTableView:i];
                break;
            }
            
        }
        
    }
    
}


#pragma mark 动态更新歌词表歌词
- (void)updateLrcTableView:(NSUInteger)lineNumber {
    //重新载入 歌词列表lrcTabView
    lrcLineNumber = lineNumber;
    [_lrcTableView reloadData];
    //使被选中的行移到中间
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:lineNumber inSection:0];
    [_lrcTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
    
}


#pragma mark - slider事件
- (void)progressAction
{
    L_Singleton *singer = [L_Singleton shareManager];
    float duration = 0;

    
    
    NSInteger currentTimeMin = singer.streamer.progress / 60;
    NSInteger currentTimeSec = (NSInteger)singer.streamer.progress % 60;
    
    self.playView.playTime.text = [NSString stringWithFormat:@"%ld:%ld", currentTimeMin, currentTimeSec];

    NSString *songDurantion = [[[[singer.array[singer.index] url_list] firstObject] objectForKey:@"duration"] description];
    
    if ([songDurantion rangeOfString:@":"].location != NSNotFound) {
        
        self.playView.surplusTime.text = [[[singer.array[singer.index] url_list] firstObject] objectForKey:@"duration"];
     
        NSInteger songTimeMin = [[self.playView.surplusTime.text substringWithRange:NSMakeRange(0, 2)] integerValue];
        NSInteger songTimeSec = [[self.playView.surplusTime.text substringWithRange:NSMakeRange(3, 2)] integerValue];
        
         duration = songTimeMin * 60 + songTimeSec;
        
    } else {
        
        
        NSInteger songTimeMin = [songDurantion integerValue] / 1000 / 60;
        NSInteger songTimeSec = [songDurantion integerValue] / 1000 % 60;
        
        self.playView.surplusTime.text = [NSString stringWithFormat:@"%ld:%ld", songTimeMin, songTimeSec];
        

        duration = [songDurantion floatValue] / 1000;
    
    }

    self.playView.progressSlider.value = singer.streamer.progress / duration;
   
    [self displaySongWord:singer.streamer.progress]; //调用歌词函
    if (singer.streamer.progress > 0) {
        
        if (singer.streamer.progress > (duration - 1)) {

            [self.time invalidate];
            
            self.playView.progressSlider.value = 0;
            
            self.time = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(progressAction) userInfo:nil repeats:YES];
            [self playModel:modelNum];
        }
    }
    
}


#pragma mark - 上一首按钮
- (void)upSongAction:(id)sender
{
    
    if ([self.single.array count] != 0) {
        self.single.index -= 1;
        if (self.single.index < 0) {
            self.single.index = 0;
        }
        
        [self updatePlayerSetting];
        
        // 赋值
        self.playView.title.text = [self.single.array[self.single.index] song_name];
        self.playView.songerName.text = [self.single.array[self.single.index] singer_name];
        [self.playView.showImage setImageWithURL:[NSURL URLWithString:[[[self.single.array[self.single.index] mv_list] firstObject] objectForKey:@"pic_url"]] placeholderImage:[UIImage imageNamed:@"playCard.jpg"]];
    }
    
    
    
}
#pragma mark - 下一首按钮
- (void)nextSongAction:(id)sender
{
    // 判断是否为空
    if ([self.single.array count] == 0) {
        
    } else {
        // 进行模式进行选择
        [self playModel:modelNum];
        
    }

}




#pragma mark - 播放(暂停)按钮
- (void)playAction:(id)sender
{
    // 判断数组是否为空
    if (self.single.array.count == 0) {
        
    } else {
    
    // 判断是否正在播放
    if ([self.single.state isEqualToString:@"playing"]) {
        // 定时器暂停
        [self.time setFireDate:[NSDate distantFuture]];
        [self.single.streamer pause];
        self.single.state = nil;
        [sender setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
        [self.playView.showImage.layer removeAnimationForKey:@"rotation"];
    } else {
            // 定时器继续
            [self.time setFireDate:[NSDate distantPast]];
            [self.single.streamer resume];
            self.single.state = @"playing";
            [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
            [self.playView.showImage.layer addAnimation:self.rotationAnimation forKey:@"rotation"];
 }
    
    //图片转动动画
    [self transform];
    
    }
    
}

#pragma mark - 图片转动动画
- (void)transform
{
    if ([self.single.state isEqualToString:@"playing"]) {
        [self.playView.showImage.layer addAnimation:self.rotationAnimation forKey:@"rotation"];
    } else {
        
        [self.playView.showImage.layer removeAnimationForKey:@"rotation"];
    }
    
}

#pragma mark - 播放模式按钮方法
- (void)playPatternAction
{
    modelNum++;
    if (modelNum > 3) {
        modelNum = 0;
    }
    self.single.modelNum = modelNum;
    
    if (modelNum == 0) {
        [self.playView.playPattern setImage:[UIImage imageNamed:@"xunhuanplay.png"] forState:UIControlStateNormal];
    } else if (modelNum == 1) {
        [self.playView.playPattern setImage:[UIImage imageNamed:@"sunxuplay.png"] forState:UIControlStateNormal];
    } else if (modelNum == 2) {
        [self.playView.playPattern setImage:[UIImage imageNamed:@"suijiplay.png"] forState:UIControlStateNormal];
    } else if (modelNum == 3) {
        [self.playView.playPattern setImage:[UIImage imageNamed:@"danquxunhuanPlay.png"] forState:UIControlStateNormal];
    }
    
}

- (void)playModel:(NSInteger)model
{
    
    switch (model) {
            
        case 0:
        {
            // 循环播放
            _isCircle = YES;
            if (_isCircle == YES) {
                self.single.index += 1;
                if (self.single.index == [self.single.array count]) {
                    self.single.index = 0;
                }
                
                [self updatePlayerSetting];
                
            }
        }
            break;
            
        case 1:
            {
                
                // 列表播放
                _isCircle = NO;
                self.single.index += 1;
                if (self.single.index >= [self.single.array count]) {
                    [self playAction:self.playView.play];
                }
                [self updatePlayerSetting];
                
                
            }
            break;
            
        case 2:
            {
                // 随机播放
                _isCircle = NO;
                NSInteger number = [self.single.array count];
                self.single.index =  arc4random() % number;
                [self updatePlayerSetting];
                
            }
            break;
            
        case 3:
            {
                // 单曲循环
                _isCircle = NO;
                [self updatePlayerSetting];
                
                
            }
            break;
            
        default:
            break;
        }
    
 
    
}


#pragma mark - 自动播放下一曲
- (void)autoplay
{
     //判断是否允许循环播放
    if (_isCircle == YES) {
        if (self.single.index == self.single.array.count - 1) {
            self.single.index = -1;
        }
        self.single.index ++;
   
        // 更新播放器设置
        [self updatePlayerSetting];
    } else {
        
        [self updatePlayerSetting];
        [self.playView.play setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
        
        
    }
    
}


#pragma mark - 更新播放器设置
- (void)updatePlayerSetting
{
    // 更新播放按钮状态
    [self.playView.play setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
    self.single.state = nil;
    
    // 更新曲目.标题等
    self.playUrl = [[[self.single.array[self.single.index] url_list] lastObject] objectForKey:@"url"];
    self.single.playUrl = self.playUrl;
    
    self.playView.title.text = [self.single.array[self.single.index] song_name];
    self.playView.songerName.text = [self.single.array[self.single.index] singer_name];
    [self.playView.showImage setImageWithURL:[NSURL URLWithString:[[[self.single.array[self.single.index] mv_list] firstObject] objectForKey:@"pic_url"]] placeholderImage:[UIImage imageNamed:@"playCard.jpg"]];
    
    
    // 重新载入歌词
    _timeArray = [[NSMutableArray alloc] initWithCapacity:10];
    _LRCDictionary = [[NSMutableDictionary alloc] initWithCapacity:10];
    [self getLRC];
    
    //播放
    [self playAction:self.playView.play];
    
    // 如果不是同一首歌, 则直接进行初始化进行播放
    [self.single playWithUrl:self.playUrl];
    self.single.state = @"playing";
    

    
}

#pragma mark - 播放列表按钮方法
- (void)playListAction:(UIButton *)button
{
    button.selected = !button.selected;
    if (button.selected) {
        [UIView transitionWithView:self.playlist.footView duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
            
            self.playlist.frame = CGRectMake(0, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - 49);
            
        } completion:^(BOOL finished) {
            
            
        }];
        
    }else{
        
        [UIView transitionWithView:self.playlist.footView duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
            
            self.playlist.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
            
        } completion:^(BOOL finished) {
            
        }];
    }
    
    
}

#pragma mark - 播放列表视图
- (void)createPlayListViews
{
    
    self.playlist = [[[L_PlayListView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT / 2 - 49)] autorelease];
    [self.view addSubview:self.playlist];
    [_playlist release];
    
}


#pragma mark - tableView协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 20100) {
        return [_timeArray count];
    }
    return self.single.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 20100) {
        static NSString *cellIdentifier = @"LRCCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;//该表格选中后没有颜色
        cell.backgroundColor = [UIColor clearColor];
        
    
        // 判断歌词时间数组的个数(如果不判断会crash)
        if (self.timeArray.count != 0) {
            if (indexPath.row == lrcLineNumber) {
                cell.textLabel.text = _LRCDictionary[_timeArray[indexPath.row]];
                //cell.textLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0];
                cell.textLabel.textColor = [UIColor yellowColor];
                //cell.textLabel.textColor = [UIColor blackColor];
                cell.textLabel.font = [UIFont systemFontOfSize:17];
            } else {
                cell.textLabel.text = _LRCDictionary[_timeArray[indexPath.row]];
                cell.textLabel.textColor = [UIColor whiteColor];
                cell.textLabel.font = [UIFont systemFontOfSize:15];
            }
        }
        cell.textLabel.backgroundColor = [UIColor clearColor];
        //        cell.textLabel.textColor = [UIColor blackColor];
        
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        
        //        [cell.contentView addSubview:lable];//往列表视图里加 label视图，然后自行布局
        //}
        return cell;

        
    }
    return nil;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 35;
}


- (void)backButtonAction
{
    L_footPlaytabBar *footPlayBar = [L_footPlaytabBar shareTabBar];
    footPlayBar.footPlayView.songName.text = [self.single.array[self.single.index] song_name];
    footPlayBar.footPlayView.songerName.text = [self.single.array[self.single.index] singer_name];
    [footPlayBar.footPlayView.mainImage setImageWithURL:[NSURL URLWithString:[[[self.single.array[self.single.index] mv_list] firstObject] objectForKey:@"pic_url"]] placeholderImage:[UIImage imageNamed:@"lloo.png"]];
    
    [self.time invalidate];
    [footPlayBar.time setFireDate:[NSDate distantPast]];
    [self dismissViewControllerAnimated:YES completion:^{
        // 模态返回页面
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
    
@end
